<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:pe="http://primefaces.org/ui/extensions"
	template="/WEB-INF/template/defaultLayout.xhtml">

	<ui:define name="title">Auction House</ui:define>
	<ui:define name="body">

		<h:form id="collaborateursListForm" style="width:95%">

			<p:dataTable id="listCollaborateurs" var="collaborateurs"
				value="#{collaboratorsOverviewBB.collaborators}" editable="true"
				rows="15" paginator="true"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">

				<f:facet name="header">#{i18n.listOfCollaborators}</f:facet>
				<p:ajax event="rowEdit" listener="#{collaboratorsOverviewBB.onEdit}" />
				<p:ajax event="rowEditCancel"
					listener="#{collaboratorsOverviewBB.onCancel}" />


				<p:column headerText="#{i18n.company}"
					sortBy="#{collaborateurs.company.name}"
					filterBy="#{collaborateurs.company.name}">
					<div align="center">
						<h:outputText value="#{collaborateurs.company.name}" />
					</div>
				</p:column>
				<p:column headerText="#{i18n.lastName}"
					sortBy="#{collaborateurs.nom}">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{collaborateurs.lastName}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{collaborateurs.lastName}"
								style="width:150px" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="#{i18n.firstName}"
					sortBy="#{collaborateurs.preNom}">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{collaborateurs.firstName}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{collaborateurs.firstName}"
								style="width:150px" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="#{i18n.jobTitle}"
					filterBy="#{collaborateurs.fonction}"
					sortBy="#{collaborateurs.fonction}">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{collaborateurs.position}" />
						</f:facet>
						<f:facet name="input">
							<p:selectOneMenu value="#{collaborateurs.position}"
								style="width:150px">
								<f:selectItem itemLabel="Select One" itemValue="" />
								<f:selectItem itemLabel="T - Tester" itemValue="Tester" />
								<f:selectItem itemLabel="DEV - Developer" itemValue="Developer" />
								<f:selectItem itemLabel="PM - Project manager"
									itemValue="Project manager" />
							</p:selectOneMenu>
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="#{i18n.technology}"
					sortBy="#{collaborateurs.technology}">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{collaborateurs.technology}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{collaborateurs.technology}"
								style="width:50px" />
						</f:facet>
					</p:cellEditor>
				</p:column>
				<p:column headerText="#{i18n.salary}"
					sortBy="#{collaborateurs.salary}" style="width:100px">
					<p:cellEditor>
						<f:facet name="output">
							<h:outputText value="#{collaborateurs.salary}" />
						</f:facet>
						<f:facet name="input">
							<p:inputText value="#{collaborateurs.salary}" style="width:100px" />
						</f:facet>
					</p:cellEditor>
				</p:column>

				<p:column headerText="#{i18n.edit}" style="width:8px">
					<p:rowEditor icon="ui-icon-pencil" />
				</p:column>

				<p:column headerText="#{i18n.downloadCV}" style="width:150px">
					<div align="center">
						<p:commandLink id="downloadLink" value="Download" ajax="false"
							disabled="#{collaboratorsOverviewBB.renderDownloadLink(collaborateurs)}">
							<p:fileDownload
								value="#{collaboratorsOverviewBB.fileDownload(collaborateurs)}" />
						</p:commandLink>
					</div>
				</p:column>

				<p:column headerText="#{i18n.delete}" style="width:8px">
					<div align="center">
						<p:commandButton icon="ui-icon-trash"
							onclick="confirmDeleteCol.show();"
							update=":collaborateursListForm:listCollaborateurs">
							<f:setPropertyActionListener
								target="#{collaboratorsOverviewBB.selectedToDeleteCollaborator}"
								value="#{collaborateurs}" />
						</p:commandButton>
					</div>
				</p:column>
			</p:dataTable>
			<p:confirmDialog id="confirmDeleteCol" widgetVar="confirmDeleteCol"
				message="#{i18n.confirmDelete} #{collaborateurs.nom}">
				<p:commandButton value="#{i18n.yes}"
					action="#{collaboratorsOverviewBB.deleteCollaborateur}"
					update="collaborateursListForm:listCollaborateurs"
					oncomplete="confirmDeleteCol.hide();" />
				<p:commandButton value="#{i18n.no}"
					onclick="confirmDeleteCol.hide();" />
			</p:confirmDialog>
		</h:form>


	</ui:define>
</ui:composition>